Frontend Forever App
We have a mobile app for you to download and use. And you can unlock many features in the app.
Get it now
Intall Later
Run
HTML
CSS
Javascript
Output
Document
@charset "UTF-8"; @import url(https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,600,700,800); *, :after, :before { box-sizing: border-box; padding: 0; margin: 0; } body { overflow: hidden; background: #0d0d0d; } .hamburger { position: fixed; top: 30px; right: 50%; transform: translateX(50%); background-color: #f1f1f1; border-radius: 150px; height: 50px; width: 50px; outline: 1px solid blue; display: flex; justify-content: center; align-items: center; } .line { position: absolute; display: block; height: 2.5px; background-color: #0d0d0d; transition: transform 0.3s ease-out, opacity 0.1s ease-out 0.3s } .l1 { transform: translateY(-10px); width: 50%; } .l2 { width: 75%; } .l3 { transform: translateY(10px); width: 50%; } .hamburger.active .l1 { transform: translateY(0); width: 75%; transform: rotate(135deg); } .hamburger.active .l2 { opacity: 0; } .hamburger.active .l3 { transform: translateY(0); width: 75%; transform: rotate(-135deg); }
console.log("Event Fired") const hamburgerButton = document.querySelector(".hamburger") hamburgerButton.addEventListener("click", toggleNav) function toggleNav (){ hamburgerButton.classList.toggle("active") }